package com.starter.jienlee.controller;

import com.starter.jienlee.common.RestResult;
import com.starter.jienlee.common.param.LoginRegisterParam;
import com.starter.jienlee.service.UserUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author jien.lee
 */
@RestController
public class MainController {

    @Autowired
    private UserUserService userService;

    @RequestMapping("/login")
    public RestResult login(LoginRegisterParam loginRegisterParam) {
        Map<String, String> result = userService.doLogin(loginRegisterParam);
        return RestResult.success(result);
    }

    @RequestMapping("/register")
    public RestResult register(LoginRegisterParam loginRegisterParam) {
        userService.toRegister(loginRegisterParam);
        return RestResult.success();
    }
}
